package com.dw.common.bean;

import com.google.common.base.Objects;
import lombok.Data;

@Data
public class ResourceBean {
    private String name;

    private long length;

    private long offset;

    private String owner;

    @Override
    public String toString() {
        return owner + ":" + name + ":" + length;
    }

    public String getPrefix() {
        return owner + ":" + name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ResourceBean that = (ResourceBean) o;
        return length == that.length && Objects.equal(name, that.name) && Objects.equal(owner, that.owner);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(name, length, owner);
    }
}
